Scalar-valued Functions [dbo].[fn_asi_GetDupMatchKey]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@Idvarchar(10)10
SQL Script
/****** Object:  Function dbo.fn_asi_GetDupMatchKey  ******/
-- =============================================
-- This stored procedure calculates the Name.DUP_MATCH_KEY value - update the formula as required
-- =============================================
create function dbo.fn_asi_GetDupMatchKey(@Id varchar(10))
returns varchar(20)
as
begin
     declare @DupMatchKey varchar(20)
     select @DupMatchKey = UPPER(dbo.fn_asi_convert_foreign_string(SUBSTRING(Name.ZIP,1,5) + (CASE WHEN Name.LAST_NAME<>'' THEN (SUBSTRING(Name.LAST_NAME,1,4) + SUBSTRING(Name.FIRST_NAME,1,1)) ELSE SUBSTRING(Name.COMPANY,1,5) END))) from Name where ID=@Id
     
     return @DupMatchKey
end

GO
Uses
Used By